<?php
/***************************************************************************
 *					admin_board.php
 *				  -------------------
 *	 begin		  : Thursday, Jul 12, 2001
 *	 copyright	  : (C) 2001 The phpBB Group
 *	 email		  : support@phpbb.com
 *
 * Last modification made by CPG Dev Team http://cpgnuke.com:
 *
 ***************************************************************************/
if (!defined('ADMIN_PAGES')) { exit; }
global $lang;

# Pull all config data
$board_config = BoardCache::conf();

if ('POST' === $_SERVER['REQUEST_METHOD'])
{
/*
	$removed = array(
		'allow_namechange',
		'allow_avatar_local',
		'allow_avatar_remote',
		'allow_avatar_upload',
		'allow_forums_privileges',
		'allow_pm_attach'
		'allow_post_reporting',
		'allow_theme_create',
		'avatar_filesize',
		'avatar_gallery_path',
		'avatar_max_height',
		'avatar_max_width',
		'avatar_path',
		'board_disable',
		'board_email',
		'board_email_form',
		'board_email_sig',
		'board_startdate',
		'board_timezone',
		'config_id',
		'cookie_domain',
		'cookie_name',
		'cookie_path',
		'cookie_secure',
		'coppa_fax',
		'coppa_mail',
		'default_lang',
		'default_pm_quota',
		'default_style',
		'enable_confirm',
		'group_forums_privileges',
		'group_post_reporter',
		'gzip_compress',
		'max_attachments_pm',
		'max_inbox_privmsgs',
		'max_filesize_pm',
		'max_savebox_privmsgs',
		'max_sentbox_privmsgs',
		'max_sig_chars',
		'notify_post_reporter',
		'override_user_style',
		'privmsg_disable',
		'record_online_date',
		'record_online_users',
		'require_activation',
		'ropm_quick_reply_bbc',
		'sendmail_fix',
		'script_path',
		'server_name',
		'server_port',
		'session_length',
		'site_desc',
		'sitename',
		'smilies_path',
		'smtp_delivery',
		'smtp_host',
		'smtp_password',
		'smtp_username',
		'version',
		'1',
	);
	$db->exec("DELETE FROM " . CONFIG_TABLE . " WHERE config_name IN ('" . implode("','",$removed) . "')");
*/
	$options = array(
		'flood_interval',
		'topics_per_page',
		'posts_per_page',
		'hot_threshold',
		'default_dateformat',
		'archive_enable',
		'prune_enable',
		'allow_topic_recycle',
		'topic_recycle_forum',
		'allow_online_index',
		'online_index_group',
		'allow_online_today',
		'online_today_group',
		'admin_color',
		'moderator_color',
		'member_color',
		'allow_online_posts',
		'restricted_group',
		'max_poll_options',
		'allow_html',
		'allow_html_tags',
		'allow_bbcode',
		'allow_smilies',
		'allow_sig',
		'allow_forum_watch',
		'allow_user_cloak',
		'allow_cloak_group',
		'edit_last_post_only',
		'allow_guest_captcha',
		'ropm_quick_reply',
	);
	foreach ($options as $config_name)
	{
		$value = isset($_POST[$config_name]) ? $_POST[$config_name] : '';
		$db->exec("UPDATE " . CONFIG_TABLE . " SET
		config_value = " . $db->quote($value) . "
		WHERE config_name = " . $db->quote($config_name));
	}
	BoardCache::cacheDelete('board_config');

	$message = $lang['Config_updated'] . "<br /><br />" . sprintf($lang['Click_return_config'], "<a href=\"".URL::admin("&amp;do=config")."\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"".URL::admin($op)."\">", "</a>");
	message_die(GENERAL_MESSAGE, $message);
	return;
}

$result = $db->query("SELECT
	f.forum_id id,
	f.forum_name name,
	CASE WHEN f.forum_id = {$board_config['topic_recycle_forum']} THEN 1 ELSE 0 END current
FROM ".FORUMS_TABLE." f, ".CATEGORIES_TABLE." c
WHERE c.cat_id = f.cat_id
ORDER BY c.cat_order ASC, f.forum_order ASC");

$template->set_filenames(array('body' => 'admin/forums/config'));

$template->assign_vars(array(
	'forum_cfg' => $board_config,
	'recycle_forums' => $result,

	'ONLINE_INDEX_GROUP' => group_selectbox('online_index_group', $board_config['online_index_group'], false, true),
	'ONLINE_TODAY_GROUP' => group_selectbox('online_today_group', $board_config['online_today_group'], false, true),
	'RESTRICTED_GROUP'   => bbgroup_select('restricted_group', $board_config['restricted_group']),
	'ALLOW_CLOAK_GROUP'  => group_selectbox('allow_cloak_group', $board_config['allow_cloak_group'], false, true),
));
